from django.db import models

# Create your models here.


class TbFirstRunning(models.Model):
    controller = models.CharField(db_column='Controller', max_length=255,db_index=True)  # Field name made lowercase.
    red = models.CharField(db_column='Red', max_length=255)  # Field name made lowercase.
    green = models.CharField(db_column='Green', max_length=255)  # Field name made lowercase.
    yellow = models.CharField(db_column='Yellow', max_length=255)  # Field name made lowercase.
    in_time = models.DateTimeField(db_index=True)

    class Meta:
        managed = False
        db_table = 'tb_first_running'


class TbFirstTh(models.Model):
    controller = models.CharField(db_column='Controller', max_length=255)  # Field name made lowercase.
    tem = models.CharField(db_column='Tem', max_length=255)  # Field name made lowercase.
    hum = models.CharField(db_column='Hum', max_length=255)  # Field name made lowercase.
    in_time = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'tb_first_th'


class TbFirstWatt(models.Model):
    gateway = models.CharField(db_column='Gateway', max_length=255)  # Field name made lowercase.
    sensortype = models.CharField(db_column='SensorType', max_length=255)  # Field name made lowercase.
    port = models.CharField(db_column='Port', max_length=255)  # Field name made lowercase.
    voltage = models.CharField(db_column='Voltage', max_length=255)  # Field name made lowercase.
    a_voltage = models.FloatField(db_column='a_Voltage', blank=True, null=True)  # Field name made lowercase.
    b_voltage = models.FloatField(db_column='b_Voltage', blank=True, null=True)  # Field name made lowercase.
    c_voltage = models.FloatField(db_column='c_Voltage', blank=True, null=True)  # Field name made lowercase.
    current = models.CharField(db_column='Current', max_length=255)  # Field name made lowercase.
    a_current = models.FloatField(db_column='a_Current', blank=True, null=True)  # Field name made lowercase.
    b_current = models.FloatField(db_column='b_Current', blank=True, null=True)  # Field name made lowercase.
    c_current = models.FloatField(db_column='c_Current', blank=True, null=True)  # Field name made lowercase.
    power = models.CharField(db_column='Power', max_length=255)  # Field name made lowercase.
    a_power = models.FloatField(db_column='a_Power', blank=True, null=True)  # Field name made lowercase.
    b_power = models.FloatField(db_column='b_Power', blank=True, null=True)  # Field name made lowercase.
    c_power = models.FloatField(db_column='c_Power', blank=True, null=True)  # Field name made lowercase.
    t_power = models.FloatField(db_column='t_Power', blank=True, null=True)  # Field name made lowercase.
    energy = models.CharField(db_column='Energy', max_length=255)  # Field name made lowercase.
    j_energy = models.FloatField(db_column='j_Energy', blank=True, null=True)  # Field name made lowercase.
    in_time = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'tb_first_watt'



class UnmState(models.Model):
    controller = models.CharField(db_column='Controller', max_length=255)  # Field name made lowercase.
    state = models.CharField(max_length=255)
    start_time = models.DateTimeField()
    last_time = models.DateTimeField()

    class Meta:
        managed = False
        db_table = 'unm_state'


class UnmStateNew(models.Model):
    controller = models.CharField(db_column='Controller', max_length=255)  # Field name made lowercase.
    state = models.CharField(max_length=255)
    start_time = models.DateTimeField()
    last_time = models.DateTimeField()
    equipment_name = models.CharField(max_length=20)
    class Meta:
        db_table = 'tb_unm_state_new'

class TbMachineGantt(models.Model):
    gw_id = models.CharField(max_length=100)
    state = models.IntegerField()
    nomal = models.IntegerField()
    exception = models.IntegerField()
    standby = models.IntegerField()
    stop = models.IntegerField()
    lost = models.IntegerField()
    start_time = models.DateTimeField()
    last_time = models.DateTimeField()
    class Meta:
        db_table = 'tb_machine_gantt'


class TbTempMachineState(models.Model):
    gw_id = models.CharField(max_length=100)
    controller = models.CharField(max_length=40)
    rc = models.DateTimeField()
    red = models.CharField(max_length=10)
    green = models.CharField(max_length=10)
    yellow = models.CharField(max_length=10)
    class Meta:
        db_table = 'tb_temp_machine_state'

class TbMachineState1(models.Model):
    gw_id = models.CharField(max_length=100)
    time = models.DateTimeField()
    yellow = models.CharField(max_length=10, blank=True, null=True)  # Field name made lowercase.
    red = models.CharField(max_length=10, blank=True, null=True)  # Field name made lowercase.
    green = models.CharField(max_length=10, blank=True, null=True)  # Field name made lowercase.

    class Meta:
        db_table = 'tb_machine_state1'

class Sen(models.Model):
    sanse_deng_id = models.CharField(max_length=11)
    equipment_name = models.CharField(max_length=100)
    sanse_deng = models.CharField(max_length=100)
    equipment_id = models.CharField(max_length=100)
    equipment_type = models.CharField(max_length=100)
    sensors_type = models.CharField(max_length=100)

    class Meta:
        db_table = 'sanse_deng_list'

